<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4426：[Nwerc2015]Better Productivity最大生产率</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Nwerc2015]Better Productivity最大生产率</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Nwerc2015]Better Productivity最大生产率</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Nwerc2015]Better Productivity最大生产率                </h1>
                <p>时间限制：1s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：1024MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>ACME Inc. is reorganizing their factory, in order to maximize their productivity of useless trinkets. The new factory design consists of p independent and identical production lines. Each production line can be assigned some number of workers.</div>
<div>The actual work is of course all done by machines, so the production rate of a production line is independent of the actual number of workers assigned to it. However, the workers work in shifts, and due to local safety regulations, a production line can only be active while all of its workers are present (any worker who arrives before the last person to arrive, or leaves after the first person leaves, will be spending the inactive time having a coffee break). In other words, the productivity of a production line equals the length of the timespan during which all of the workers assigned to this production line are present. Crucially, the productivity of each line must be positive (i.e., the last worker to arrive for a line must arrive strictly before the first worker for that line leaves), since otherwise the workers feel that their jobs are meaningless.</div>
<div>Unfortunately, due to some pesky labor laws, ACME are not allowed to fire any of their workers, which means that each of their n workers must be assigned to some production line, even though this may actually decrease the overall productivity of the factory.</div>
<div>All these rules and regulations are making a headache for ACME management. Can you help them figure out the maximum possible total productivity (sum of productivities of the p production lines) of their new factory?</div>
<div></div>
<div>ACME公司正在重组他们的工厂，以最大化他们生产无用的小饰品的效率。新工厂由相同的p个独立生产线组成。每一条生产线都可以被分配一些员工。</div>
<div></div>
<div>实际的工作都是由机器完成，所以一条生产线的效率是由分配给它的员工数量决定的。但是，员工们轮班工作，而且由于当地安全法规定，一条生产线只有在被分配给它的员工都正在工作岗位上时，才能开启（任何比最后到的员工先到或比最先离开的员工后离开的员工，会用时间来喝咖啡休息）。换句话说，生产线的生产效率等于它的所有员工都在岗位上的时间长度。最重要的是，生产线的生产效率必须为正数（即最晚到达的员工到达的时间必须严格早于最早离开的员工离开的时间），否则工人们会认为他们的工作没有意义。</div>
<div></div>
<div>不幸的是，由于讨厌的劳动法，ACME不能解雇他们的员工，这就意味着，他们的n个员工每一个都要分配到某一个生产线，即使这会降低工厂的生产率。</div>
<div></div>
<div>这些规定正使ACME的高层们头疼，你能帮他们弄清他们的新工厂的最大生产率（p个生产线生产率总和）吗？</div>
<p></p></p><hr/><h3>输入格式</h3><p><div>The input consists of:</div>
<div>&bull;<span class="Apple-tab-span" style="white-space: pre;">	</span>one line containing two integers n and p (1&le;p&le;n&le;2001&le;p&le;n&le;200), the number of employees and the number of production lines;</div>
<div>&bull;<span class="Apple-tab-span" style="white-space: pre;">	</span>n lines each containing two integers a and b(0&le;a&lt;b&le;1000000&le;a&lt;b&le;100000), representing a worker that arrives at time a and leaves at time b.</div>
<div>You may assume that there exists at least one valid assignment of workers to production lines.</div>
<div>输入包括：</div>
<div>第一行包括两个整数n和p（1&lt;=p&lt;=n&lt;=200）,n是员工数量，p是生产线数量。</div>
<div>接下来n行每行包括两个整数a和b（0&lt;=a&lt;b&lt;=100000）,描述了一个员工在a时刻到达，b时刻离开。</div>
<div>你可以认为至少存在一个有效解。</div>
<p></p></p><hr/><h3>输出格式</h3><p><div>Output the maximum productivity level possible for the factory.</div>
<div>输出这个工厂可能的最大生产率。</div>
<p></p></p><hr/><h3>样例输入</h3><pre>4 2
1 3
1 5
4 6
2 7</pre><hr/><h3>样例输出</h3><pre>4
</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4426" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4426" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>